<?php /* SVN: $Id: add.ctp 2802 2010-08-19 15:25:43Z sathishkumar_123at09 $ */ ?>
<div class="projectFunds form user-profile-form pledge-form round-5 clearfix">
	<div class="project-funds-add grid_12">
		<div class="l-curve-top">							
			<div class="r-curve-top">
				<div class="top-bg"></div>
			</div>
		</div>
		<div class="shad-bg-lft clearfix">
			<div class="shad-bg-rgt">
				<div class="shad-bg">
					<div class="main-section">
                      <?PHP if(($project['Project']['project_status_id'] == ConstProjectStatus::ReserveAmountReached) || ($project['Project']['project_status_id'] == ConstProjectStatus::GoalReached)){ $link = "Fund"; ?>
							<div class='content-info'><?php echo __l('We will capture this amount.'); ?></div>
                       <?PHP } else{ $link = "Pledge"; ?>
                            <div class='content-info'><?php echo __l('We will authorize the pledge amount.  This amount will be captured only when the project reaches the goal.'); ?></div>
                       <?PHP }?>
						<?php echo $this->Form->create('ProjectFund', array('class' => 'normal js-fund-form clearfix'));?>
							<?php
								echo $this->Form->input('latitude',array('type' => 'hidden', 'id'=>'latitude'));
								echo $this->Form->input('longitude',array('type' => 'hidden', 'id'=>'longitude'));
								echo $this->Form->input('project_id',array('type'=>'hidden'));
								if (!empty($project['ProjectReward'])):
									echo $this->Form->input('project_reward_id',array('type'=>'hidden'));
								endif;
								if ($project['Project']['pledge_type_id'] == ConstPledgeTypes::Reward) {
									echo $this->Form->input('amount',array('type' =>'hidden'));
								}
								if ($project['Project']['pledge_type_id'] == ConstPledgeTypes::Fixed ) {
									echo $this->Form->input('amount',array('readonly'=>true,'label' => __l('Pledge amount') .' ('.Configure::read('site.currency').')'));
								} else {
									echo $this->Form->input('amount',array('label' => __l('Pledge amount') .' ('.Configure::read('site.currency').')'));
								}
							?>
							<?php if (!empty($project['ProjectReward'])): ?>
								<h2><?php echo __l('Select your reward'); ?></h2>
								<?php
									if ($project['Project']['pledge_type_id'] != ConstPledgeTypes::Reward ) {
										$options = array(0 => '<span>' . __l('No Reward') . '</span>');
										echo $this->Form->input('project_reward', array('type' => 'radio', 'options' => $options, 'after' => '<span>'.__l('No thanks, I just want to help the project.') .'</span>','class' => 'js-reward-input {reward:-1}'));
									}
									foreach ($project['ProjectReward'] as $reward) :
										$disabled = false;
										if ($reward['pledge_max_user_limit'] > 0 and $reward['pledge_max_user_limit'] <= $reward['project_fund_count']) :
											$disabled = 'disabled';
										elseif($reward['pledge_amount'] > ($project['Project']['needed_amount'] - $project['Project']['collected_amount']) && !($project['Project']['is_allow_over_funding'])):	
											$disabled = 'disabled';
										endif;
								?>
										<div class="rewards">
											<?php if ($disabled) :?>
												<div class="input radio">
												<div class="round-3 sold-out <?php echo $disabled;?>"><span><?php echo __l('Sold out');?></span></div>
												<span><?php echo Configure::read('site.currency').$reward['pledge_amount'].' + '; ?></span>
												<span><?php echo $reward['reward']; ?></span></div>
											<?php else:?>
												<?php echo $this->Form->input('project_reward', array('type' => 'radio','id'=>'reward_'.$reward['id'],'options' => array($reward['id'] => Configure::read('site.currency').$reward['pledge_amount'].' +'), 'after' => '<span>'.$reward['reward'].'</span>', 'disabled' => $disabled, 'class' => 'js-reward-input {reward: '.$reward['id'].',amount: '.$this->Html->cInt($reward['pledge_amount'],false).'} '.$disabled));?>
											<?php endif; ?>
										</div>
								<?php endforeach; ?>
							<?php endif; ?>
							<div class="submit-block clearfix"> <?php echo $this->Form->submit(__l($link),array('title' => __l($link)));?> </div>
						<?php echo $this->Form->end();?>
					</div>
				</div>
			</div>
		</div>
		<div class="l-curve-bot">							
			<div class="r-curve-bot">
				<div class="bot-bg"></div>
			</div>
		</div>
	</div>
	<div class="pledge-questions grid_11">
		<div class="l-curve-top">							
			<div class="r-curve-top">
				<div class="top-bg"></div>
			</div>
		</div>
		<div class="shad-bg-lft clearfix">
			<div class="shad-bg-rgt">
				<div class="shad-bg">
					<div class="main-section">
						<div class="clearfix pledge-img-block">
							<div class="pledge-img grid_4">
								<?php
									echo $this->Html->link($this->Html->showImage('Project', $project['Attachment'], array('dimension' => 'small_big_thumb', 'alt' => sprintf(__l('[Image: %s]'), $this->Html->cText($project['Project']['name'], false)), 'title' => $this->Html->cText($project['Project']['name'], false)),array('aspect_ratio'=>1)), array('controller' => 'projects', 'action' => 'view',  $project['Project']['slug'], 'admin' => false), array('escape' => false)); 
								?>
							</div>
							<div class="pledge-amount project-left grid_5">
								<h3><?php echo $this->Html->link($this->Html->cText($project['Project']['name'],false),array('controller' => 'projects', 'action' => 'view',  $project['Project']['slug'], 'admin' => false), array('escape' => false));?></h3>
								<p> <?php echo __l('by') . ' '; ?><?php echo $this->Html->link($this->Html->cText($project['User']['username']), array('controller' => 'users', 'action' => 'view', $project['User']['username']), array('escape' => false));?></p>
								<p><?php echo __l('Funding ends ').$this->Time->cDate($project['Project']['project_funding_end_date']); ?></p>
								<?php  $collected_percentage = ($project['Project']['collected_percentage']) ? $project['Project']['collected_percentage'] : 0; ?>
								<div class="progress-block round-5">
									<p class="progress-bar progress-bar-amount round-5" title = '<?php echo $this->Html->cFloat($collected_percentage,false).'%'; ?>'>
										<span class="round-5" style="width:<?php echo ($collected_percentage > 100) ? '100%' : $collected_percentage.'%'; ?>;" title = "<?php echo $this->Html->cFloat($collected_percentage,false).'%'; ?>"><?php echo Configure::read('site.currency').$project['Project']['collected_amount'];?></span>
									</p>
									<p><?php echo Configure::read('site.currency'). $this->Html->cCurrency($project['Project']['collected_amount']); ?> / <?php echo Configure::read('site.currency'). $this->Html->cCurrency($project['Project']['needed_amount']); ?></p>
								</div>
								<dl class="list">
									<dt><?php echo __l('Backers: '); ?></dt>
										<dd><?php echo $this->Html->cInt($project['Project']['project_fund_count']); ?></dd>
								</dl>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="l-curve-bot">							
			<div class="r-curve-bot">
				<div class="bot-bg"></div>
			</div>
		</div>
		<?php echo $this->element('reward-info', array('config' => 'sec')); ?>
	</div>
</div>